home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / dev / misc / gms_dev.lha / GMS / Source / Asm / Sprites / Sprite.s < prev   
Encoding:
Text File  |  1997-07-09  |  3.6 KB  |  130 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Name:      Sprite Example
  3. ;Author:    Paul Manias
  4. ;Copyright: DreamWorld Productions (c) 1996-1997.  Freely distributable.
  5. ;
  6. ;This example shows you how to set up a 16 colour OCS sprite with a doubled
  7. ;X axis (32 pixels width).  Those with hardware experience will know that it
  8. ;takes 4 sprite banks to do this successfully in OCS, which leaves you with
  9. ;another 4 banks to do with what you will.
  10. ;
  11. ;Notice that the screen is only 1 bitplane large, even though the sprite is
  12. ;16 colours.  This is because the sprite is independent of the screen
  13. ;bitmap.  You can access colours not in the screen by setting up a large
  14. ;palette and specifying the amount of colours in GS_AmtColours (in this
  15. ;case, we set 32 colours to access the sprite colour bank).
  16. ;
  17. ;Try moving the sprite around a bit with the mouse.  The LMB exits the demo.
  18.  
  19.     INCDIR    "INCLUDES:"
  20.     INCLUDE    "games/games_lib.i"
  21.     INCLUDE    "games/games.i"
  22.  
  23.     SECTION    "Demo",CODE
  24.  
  25. ;===========================================================================;
  26. ;                             INITIALISE DEMO
  27. ;===========================================================================;
  28.  
  29.     STARTGMS
  30.  
  31. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  32.     move.l    GMSBase(pc),a6
  33.     lea    ScreenTags(pc),a0
  34.     CALL    AddScreen
  35.     tst.l    d0
  36.     beq.s    .Error_Screen
  37.  
  38.     move.l    Screen(pc),a0
  39.     lea    SparkieTags(pc),a1
  40.     CALL    InitSprite
  41.     tst.l    d0
  42.     beq.s    .Error_Sparkie
  43.  
  44.     CALL    ShowScreen
  45.  
  46.     bsr.s    Main
  47.  
  48.     CALL    InitJoyPorts    ;Initialise ports.
  49.  
  50. .ReturnToDOS
  51.     move.l    GMSBase(pc),a6
  52.     move.l    Sparkie(pc),a1
  53.     CALL    FreeSprite
  54. .Error_Sparkie
  55.     move.l    Screen(pc),a0
  56.     CALL    DeleteScreen
  57. .Error_Screen
  58.     MOVEM.L    (SP)+,A0-A6/D1-D7
  59.     moveq    #ERR_OK,d0
  60.     rts
  61.  
  62. ;===========================================================================;
  63. ;                                MAIN LOOP
  64. ;===========================================================================;
  65.  
  66. Main:    move.l    Sparkie(pc),a1
  67. .loop    addq.w    #1,d7    ;Animation/Frame delay, so that
  68.     btst    #0,d7    ; our anim does not run too fast!
  69.     beq.s    .Mouse
  70.     cmp.w    #5,SPR_Frame(a1)    ;Do the animation for the sprite.
  71.     beq.s    .reset    ;(simply by increasing the frame
  72.     addq.w    #1,SPR_Frame(a1)    ; number).
  73.     bra.s    .Mouse
  74. .reset    clr.w    SPR_Frame(a1)
  75.  
  76. .Mouse    moveq    #JPORT1,d0    ;Read from port 1
  77.     moveq    #JT_ZBXY,d1
  78.     CALL    ReadJoyPort    ;Go get mouse position.
  79.     move.w    d0,d1
  80.     asr.w    #8,d0
  81.     add.w    d0,SPR_XPos(a1)
  82.     ext.w    d1
  83.     add.w    d1,SPR_YPos(a1)
  84.     CALL    WaitVBL    ;Wait for a VBL.
  85.     CALL    UpdateSprite    ;Put Sparkie on the screen.
  86.     btst    #MB_LMB,d0
  87.     beq.s    .loop
  88.     rts
  89.  
  90. ;===========================================================================;
  91. ;                                  DATA
  92. ;===========================================================================;
  93.  
  94. SparkieTags
  95.     dc.l    TAGS_SPRITE
  96. Sparkie    dc.l    0
  97.     dc.l    SPA_Data,Gfx_Sparkie
  98.     dc.l    SPA_XCoord,100
  99.     dc.l    SPA_YCoord,100
  100.     dc.l    SPA_Width,16
  101.     dc.l    SPA_Height,21
  102.     dc.l    SPA_AmtColours,16
  103.     dc.l    SPA_ColStart,16
  104.     dc.l    SPA_Planes,2
  105.     dc.l    SPA_Attrib,XLONG
  106.     dc.l    TAGEND
  107.  
  108. ScreenTags:
  109.     dc.l    TAGS_GAMESCREEN
  110. Screen:    dc.l    0
  111.     dc.l    GSA_Palette,.palette
  112.     dc.l    GSA_AmtColours,32
  113.     dc.l    GSA_Planes,1
  114.     dc.l    GSA_Attrib,SPRITES|NOSCRBDR
  115.     dc.l    TAGEND
  116. .palette
  117.     dc.l    $000000,$000000,$000000,$000000,$000000,$000000,$000000,$000000
  118.     dc.l    $000000,$608080,$406060,$304040,$C0C000,$908000,$807000,$605000
  119.     dc.l    $10C020,$005000,$B000B0,$600060,$F02000,$901000,$B0B0B0,$F0F0F0
  120.     dc.l    $00B0F0,$006080,$506080,$90B0F0,$F0F000,$E0E000,$B0A000,$504000
  121.  
  122. ;===========================================================================;
  123. ;                         ALL CHIP RAM DATA HERE
  124. ;===========================================================================;
  125.  
  126.     SECTION    "Graphics",DATA_C
  127.  
  128. Gfx_Sparkie:
  129.     INCBIN    "GMS:demos/data/RAW.Sparkie"
  130.